package wicketcool;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import wicketcool.plugins.InfoPlugin;
import wicketcool.plugins.Plugin;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: rabbit
 * Date: Jul 13, 2009
 */
@Component("core")
public class DefaultCore implements Core {

    @Autowired
    private Map<String, Plugin> plugins;

    private Map<String, String> properties;

    @PostConstruct
    public void post() {
        InfoPlugin infoPlugin = (InfoPlugin) plugins.get("info");
        infoPlugin.setPlugins(plugins);

        properties = new HashMap<String, String>();
        properties.put("domain.module.path", new String());
    }

    public void executePlugin(String pluginName, List<String> arguments)
            throws PluginDoesNotExistsException {

        if (plugins.containsKey(pluginName)) {
            plugins.get(pluginName).run(arguments);
        } else {
            throw new PluginDoesNotExistsException(pluginName);
        }

    }
}
